<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
	require_once("connect/dbcon.php");
	if(isset($_POST['un']))
		{
			$username=$_POST['un'];
			$password=$_POST['pa'];
			
			$sql=sprintf("select * from khachhang where UserName='%s' AND Password='%s'",$username,$password);
			$user=mysql_query($sql);
			
			if(mysql_num_rows($user)==1)	
				{  // thanh cong
				$row_user=mysql_fetch_assoc($user);
				$_SESSION['HoTen']=$row_user['HoTen'];
				$_SESSION['UserName']=$row_user['UserName'];
				$_SESSION['DiaChi']=$row_user['DiaChi'];
				$_SESSION['DienThoai']=$row_user['DienThoai'];
				$_SESSION['Email']=$row_user['Email'];
				$_SESSION['PhanQuyen']=$row_user['PhanQuyen'];
				
				
				$_SESSION['url_hientai']=$_SERVER['REQUEST_URI'];
				
				}
			else 
				{
					$thongbao="Đăng nhập thất bại ! Vui lòng kiểm tra lại Username và Password.";
				}
		}
				
				

?>

</body>
</html>